package com.zzyl.nursing.config;

import com.zzyl.nursing.service.IReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.Date;

@Configuration
@EnableScheduling // 开启定时任务支持
public class ScheduleConfig {

    @Autowired
    private IReservationService reservationService;

    /**
     * cron表达式：0 1,31 * * * ? → 每小时的1分和31分执行
     */
    @Scheduled(cron = "0 1,31 * * * ?")
    public void handleExpiredReservations() {
        reservationService.handleExpiredReservations();
    }
}